<?php
//require_once ( 'mgm_application.php' );
session_start();
$mgmApps = new mgmApps();
$mgmApps->setMember();

//$_SESSION['test'] = 'test';

//echo $_SESSION['user_MGM_id'];

/*$included_files = get_included_files();

foreach ($included_files as $filename) {
    echo "$filename <br />";
}*/

?>

<?php include 'header.php';?>
    <div id="body">
    	<form id="register_form" name="register_form" method="post" action="func/mgm_register.php?do=register" >
    	<div class="reg_account-info">
            <h1>Member Registration</h1>
            <div class="frm_rows"> <div class="frm_left">Sponsor ID</div><div class="frm_right "><INPUT name="sponsorID" type="text" class="inputTextbox txtBoxdisabled" id="sponsorID" value="<?php echo $_SESSION['user_MGM_id']?>" readonly="readonly"></div></div>
            <div class="frm_rows"> <div class="frm_left">E-Mail</div><div class="frm_right"><INPUT type="text" id="email" name="email" class="inputTextbox"><div class="frm_checkemail"><div class="frm_checkemail-msg">test</div></div></div></div>
            
            <div class="frm_rows"> 
            	<div class="frm_left">URL Name</div>
                <div class="frm_right"><INPUT type="text" id="urlname" name="urlname" class="inputTextbox"><div class="frm_check"><div class="frm_check-msg">test</div></div></div>
                
            </div>
            <div class="frm_rows">
            	<div class="frm_left">Password</div>
                <div class="frm_right"><INPUT type="password" id="password" name="password" class="inputTextbox"></div>
            </div>
            <div class="frm_rows"> 
            	<div class="frm_left">Confirm password</div>
                <div class="frm_right"><INPUT type="password" id="confirm_password" name="confirm_password" class="inputTextbox"><div class="frm_checkpwd"><div class="frm_checkpwd-msg">test</div></div></div> 
            </div>
            <div class="frm_rows"></div>
        </div>
        
        
        <div class="reg_personal-info">
            <h1>Personal Info</h1>
            <div class="frm_rows">
            	<div class="frm_left">Fullname</div>
                <div class="frm_check"></div>
                <div class="frm_right"><INPUT type="text" id="fullname" name="fullname" class="inputTextbox"></div>
            </div>
            <div class="frm_rows">
            	<div class="frm_left">I/C No</div>
                <div class="frm_check"></div>
                <div class="frm_right"><INPUT type="text" id="ic_no" name="ic_no" class="inputTextbox"></div>
            </div>
            <div class="frm_rows">
            	<div class="frm_left">Address</div>
                <div class="frm_check"></div>
                <div class="frm_right"><INPUT type="text" id="address1" name="address1" class="inputTextbox"></div>
            </div>
            <div class="frm_rows">
            	<div class="frm_left"></div>
                <div class="frm_check"></div>
                <div class="frm_right"><INPUT type="text" id="address2" name="address2" class="inputTextbox"></div>
            </div>
            <div class="frm_rows">
            	<div class="frm_left">Postcode</div>
                <div class="frm_check"></div>
                <div class="frm_right"><INPUT type="text" id="postcode" name="postcode" class="inputTextbox"></div>
            </div>
            <div class="frm_rows">
            	<div class="frm_left">Country</div>
            	<div class="frm_check"></div>
            	<div class="frm_right">
                	<select name="country" id="country">
                        <option value="none" selected="selected">Please Select Country</option>
                        <!--<option value="JOH" <?php //if($_SESSION['tmp_state']==='Johor') echo 'selected="selected"';?>>Johor</option>-->
                        <option value="MY" >Malaysia</option>
                        <option value="SG" >Singapura</option>
                        <option value="BRN" >Brunei</option>
                        <option value="AUS" >Australia</option>
                        
                    </select>
                </div>
            </div>
            
            <div class="frm_rows"> 
            	<div class="frm_left">State</div>
                <div class="frm_check"></div>
            	<div class="frm_right">
                	<select name="state" id="state">
                        <option value="none" selected="selected">Please Select State</option>
                        <!--<option value="JOH" <?php //if($_SESSION['tmp_state']==='Johor') echo 'selected="selected"';?>>Johor</option>-->
                        <option value="JOH" >Johor</option>
                        <option value="KED" >Kedah</option>
                        <option value="KEL" >Kelantan</option>
                        <option value="KUL" >Kuala Lumpur</option>
                        <option value="LAB" >Labuan</option>
                        <option value="MEL" >Melaka</option>
                        <option value="NS9" >Negeri Sembilan</option>
                        <option value="PAH" >Pahang</option>
                        <option value="PEN" >Pulau Pinang</option>
                        <option value="PER" >Perlis</option>
                        <option value="PRK" >Perak</option>
                        <option value="PUT" >Putrajaya</option>
                        <option value="SBH" >Sabah</option>
                        <option value="SRW" >Sarawak</option>
                        <option value="SEL" >Selangor</option>
                        <option value="TER" >Terengganu</option>
                    </select>
                </div>
            </div>
            <div class="frm_rows">
            	<div class="frm_left">Phone No (H)</div>
                <div class="frm_check"></div>
                <div class="frm_right"><INPUT type="text" id="phone_no" name="phone_no" class="inputTextbox"></div>
            </div>
            <div class="frm_rows">
            	<div class="frm_left">Mobile Phone</div>
            	<div class="frm_check"></div>
            	<div class="frm_right"><INPUT type="text"id="mobile_no" name="mobile_no" class="inputTextbox"></div>
            </div>
            <div class="frm_rows"></div>
            
           <div class="frm_rows"></div>
        </div>
        
        <div id="notification">
        	<span class="icon-alert"></span>
        	<div id="error-msg">asas</div>
        </div>
        
        <div class="reg_payment-info">
            <h1>Payment Info</h1>
            <p>
                Payments can be made through our Bank Account.<br /><br />
                <span class="fontBold">Bank : Maybank</span><br />
                Acc Name : Stormreaders Network Sdn. Bhd<br />
                Acc No : 5627 9550 0929<br /><br />
                
                <span class="fontBold">Bank : Bank Islam</span><br />
                Acc Name : Stormreaders Network Sdn. Bhd<br />
                Acc No : 141950 1000 5638<br />
			</p>
            <br />
            <p>Please send us the Transaction Slip via :</p>
            <p>
            	1. Email us at subscribe@stormreaders.com<br />
				2. Whatsapp us the payment proof & your email address at 012-3456789</p>
    
        </div>
        
        <div class="reg_submit-btn">
            <p>
                <div class="button">Submit</div>
			</p>
        </div>
        </form>
    </div>
<?php include 'footer.php';?>

<script src="js/global.js"></script>
<script src="js/register.js"></script>

<script>
$(document).ready(function() {
	$('.frm_check, .frm_checkpwd, .frm_checkemail').hide();
	
	//var baseurl = '<?php //$mgmApps->BASEurl();?>';
	$('#urlname').blur(function(){
		var urlname = $('#urlname').val();
		checkUrl(urlname);
	});
	
	$('#email').blur(function(){
		var email = $('#email').val();
		checkEmail(email);
	});
	
	$('#confirm_password').blur(function(){
		checkPassword();
	});
	
	
	////functions ///
	
	function checktest() {
		alert('checktest');
		var checkresult = '1';
	}
	
	function checkEmail(email){
		if (email != ''){
			$.post("<?php echo $mgmApps->BASEurl();?>func/mgm_checkemail.php",{email:email}, function(response){
				if (response == '0'){
					$('.frm_checkemail').show("slide",{direction: 'down'});
					$('.frm_checkemail').delay(2000).hide("slide",{direction: 'up'});
					$('.frm_checkemail-msg').removeClass("check_pass").addClass("check_error").text("Email already in use");
					$('#email').focus();
					return false;
				} else if (response == '2'){
					$('.frm_checkemail').show("slide",{direction: 'down'});
					$('.frm_checkemail').delay(2000).hide("slide",{direction: 'up'});
					$('.frm_checkemail-msg').removeClass("check_pass").addClass("check_error").text("Incorrect Email Format");
					$('#email').focus();
					return false;
				} else {
					$('.frm_checkemail').show("slide",{direction: 'down'});
					$('.frm_checkemail').delay(2000).hide("slide",{direction: 'up'});
					$('.frm_checkemail-msg').removeClass("check_error").addClass("check_pass").text("Email is available");
					
				}
			})
		}
	}
	
	function checkUrl(urlname){
	  if (urlname != ''){
	  $.post("<?php echo $mgmApps->BASEurl();?>func/mgm_checkurl.php",{urlname:urlname}, function(response){
		  if (response == '0'){
			  $('.frm_check').show("slide",{direction: 'down'});
			  $('.frm_check').delay(2000).hide("slide",{direction: 'up'});
			  $('.frm_check-msg').removeClass("check_pass").addClass("check_error").text("URL Name already in use");
			  $('#urlname').focus();
			  return false;
		  } else {
			  $('.frm_check').show("slide",{direction: 'down'});
			  $('.frm_check').delay(2000).hide("slide",{direction: 'up'});
			  $('.frm_check-msg').removeClass("check_error").addClass("check_pass").text("URL Name is available");
			  
			  
			  }
		  })
	  }
	}
	
	function checkPassword(){
		var password = $('#password').val();
		var c_password = $('#confirm_password').val();
		if (c_password != password){
			$('.frm_checkpwd').show("slide",{direction: 'down'});
			$('.frm_checkpwd').delay(2000).hide("slide",{direction: 'up'});
			$('.frm_checkpwd-msg').removeClass("check_pass").addClass("check_error").text("Password Not Matched");
			$('#confirm_password').focus();
			return false;
		} else {
			$('.frm_checkpwd').show("slide",{direction: 'down'});
			$('.frm_checkpwd').delay(2000).hide("slide",{direction: 'up'});
			$('.frm_checkpwd-msg').removeClass("check_error").addClass("check_pass").text("Password Matched");
		}
	}
	
});
</script>



